"""
多模态-音频理解
"""
import base64
from pprint import pprint
from models import call_ali_audio_model

#  Base64 编码格式
def encode_audio(audio_file_path):
    with open(audio_file_path, "rb") as audio_file:
        return base64.b64encode(audio_file.read()).decode("utf-8")

# 请用您的本地音频的绝对路径替换 ABSOLUTE_PATH/welcome.mp3
audio_file_path = "../data/document/audio.mp3"
base64_audio = encode_audio(audio_file_path)

messages = [
    {
        "role": "system",
        "content": [{"text": "You are a helpful assistant."}]},
    {
        "role": "user",
        "content": [{"audio":f"data:audio/mp3;base64,{base64_audio}"},
                    {"text": "音频里在说什么? "}],
    }
]
pprint(call_ali_audio_model(messages))